<template>
	<div>
		<div class="custom_steps" v-for="(item, index) in allSteps" :key="index">
			<div class="mid_steps">
				<el-steps align-center space="9.375rem">
					<el-step
						v-for="(d, i) in item.topSteps"
						:key="i"
						:status="d.state == 1 ? 'finish' : ''"
					>
						<div class="step_title" slot="title" :title="d.title">{{ '董事长' }}</div>
						<div class="step_description" slot="description">{{ '222' }}</div>
					</el-step>
				</el-steps>
				<el-steps
					align-center
					space="9.375rem"
					v-if="item.bottomSteps.length"
					style="justify-content: flex-end;"
				>
					<el-step
						v-for="(d, i) in item.bottomSteps"
						icon="el-icon-success"
						:title="d.title"
						:description="d.description"
						:key="i"
						:status="d.state == 1 ? 'finish' : ''"
					>
						<div class="step_title" slot="title" :title="d.title">{{ d }}</div>
						<div class="step_description" slot="description">{{ d }}</div>
					</el-step>
				</el-steps>
			</div>
			<div class="left_steps">
				<div
					class="circle"
					:class="[item.topSteps[0].state == 1 ? 'finish' : '']"
					v-if="index >= 1"
				></div>
			</div>
			<div class="right_steps">
				<div
					class="circle"
					:class="[item.bottomSteps[item.bottomSteps.length - 1].state == 1 ? 'finish' : '']"
					v-if="item.bottomSteps.length"
				></div>
			</div>
		</div>
	</div>
</template>
 
<script>
export default {
	name: "CustomStep",
	props: {
		stepsData: {
			type: Array,
			default() {
				return [];
			},
		},
	},
	data() {
		return {
			allSteps: [],
		};
	},
	watch: {
		stepsData() {
			this._initStepsData();
		},
	},
	methods: {
		// 初始化数据
		_initStepsData() {
			const stepsData = this.stepsData;
			this.allSteps = [];
			if (stepsData && stepsData.length > 0) {
				let num = Math.ceil(stepsData.length / 14);
				let flagNum = 0;
				for (let index = 0; index < num; index++) {
					flagNum = index * 14;
					this.allSteps.push({
						topSteps: stepsData.slice(index * 14, index * 14 + 7),
						bottomSteps: stepsData.slice(flagNum + 7, flagNum + 14).reverse(),
					});
				}
			}
		},
	},
};
</script>
 
<style lang="scss" scoped>
.custom_steps {
	position: relative;
	display: flex;
	justify-content: center;
 
	.step_title {
		width: 50px;
		height:40px;
		font-size: 14px;
		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
		// overflow: hidden;
		// display: -webkit-box;
		// -webkit-line-clamp: 2;
		// -webkit-box-orient: vertical;
	}
 
	.step_description {
		height: 40px;
		font-size: 12px;
	}
	.mid_steps {
		width: 200px;
		position: relative;
		z-index: 2;
	}
	.left_steps {
		position: absolute;
		top: 5px;
		left: 1px;
		width: 100px;
		margin-right: -20px;
		z-index: 1;
		.circle {
			width: 20px;
			height: 10px;
			// margin-top: 1.1458rem;
			border: 5px solid #c0c4cc;
			border-radius: 30% 0 0 30%;
			border-right: none;
			&.finish {
				border-color: #409eff;
			}
		}
	}
 
	.right_steps {
		position: absolute;
		top: 1px;
		right: 1.5625rem;
		width: 70px;
		margin-left: -20px;
		z-index: 1;
		.circle {
			width: 60px;
			height: 50px;
			// margin-top: 1.1458rem;
			border: 5px solid #c0c4cc;
			border-radius: 0 30% 30% 0;
			border-left: none;
			&.finish {
				border-color: #409eff;
			}
		}
	}
	// ::v-deep .el-step__icon {
	//   background: #f6f6f6;
	// }
	::v-deep .el-step__icon-inner {
		font-size: 14px;
	}
	::v-deep .el-step__line {
		background: transparent;
		border-top: 5px solid;
		.el-step__line-inner {
			border-width: 0 !important;
		}
	}
 
	.el-steps {
		height:60px;
	}
 
	::v-deep .el-step {
		position: relative;
		margin: 10px 0;
		.el-step__head.is-process {
			color: #c0c4cc;
			border-color: #c0c4cc;
		}
		.el-step__title.is-process {
			color: #c0c4cc;
			font-weight: unset;
		}
	}
}
</style>